﻿@using PagedList.Mvc;
@{
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
@using (Html.BeginForm("ListPH", "ProvideHelp", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-inline" }))
{
    <div id="wrapper">
        <div class="clear-fix"></div>
        <div class="row">
            <div style=" min-heiPHt: 110px; padding-left: 30px; ">
                <h3 class="page-header">Danh sách PH</h3>
                <span style="color:orangered;">@ViewBag.Msg</span><br />
                <input type="text" name="Username" class="form-control">
                @{ DateTime a = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
                    DateTime b = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddDays(-1);
                }

                <input type="text" name="Fromdate" class="form-control inputBox" value="@a">
                <input type="text" name="Todate" class="form-control inputBox" value="@b">
                <button type="submit" class="btn_submit btn btn-default">Tìm kiếm</button>
            </div>
        </div>
        <!-- /.row -->
        <div class="row">
            <div class="col-lg-12">
                <div class="panel-body">
                    <div class="dataTable_wrapper">
                        <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                            <thead>
                                <tr style="font-family:'Times New Roman'">
                                    <th>STT</th>
                                    <th>PH User</th>
                                    <th>Created</th>
                                    <th>Status</th>
                                    <th>Value</th>
                                    <th>GH User</th>
                                    <th>GH Mobile</th>
                                    <th>Remaining</th>
                                    <th>Option</th>
                                </tr>
                            </thead>
                            <tbody style="font-family:'Times New Roman'">
                                @{int j = 0;}
                                @foreach (var item in ViewBag.PHs)
                                {

                                    j++;
                                    <tr>
                                        <td>@j</td>
                                        <td>@item.UserName</td>
                                        <td>@item.CreateDate</td>
                                        <td>@item.StatusName</td>
                                        <td>@item.Amount</td>
                                        <td></td>
                                        <td></td>
                                        <td>@item.Remaining</td>
                                        <td>
                                            
                                        </td>
                                    </tr>
                                    if (item.TransferOrder.Count > 0)
                                    {
                                        foreach (var ts in item.TransferOrder)
                                        {
                                            <tr>
                                                <td></td>
                                                <td></td>
                                                <td>@ts.CreateDate.ToString("dd/MM/yyyy hh:mm:ss")</td>
                                                @if (ts.Status == 0)
                                                {
                                                    <td>Proccesing</td>
                                                }
                                                else if (ts.Status == 1)
                                                {
                                                    <td>Bad</td>
                                                }
                                                else
                                                {
                                                    <td>Complete</td>
                                                }
                                                <td>@ts.Amount</td>
                                                <td>@ts.GH_Name</td>
                                                <td>@ts.GH_Mobile</td>
                                                <td></td>
                                                <td>
                                                    <a href='@Url.Action("ViewBadReport", "ProvideHelp", new { transId = ts.Id })'>View</a>                                                   |
                                                    @if (ts.Ph_or_Gh == 0)
                                                    {
                                                        <a href='@Url.Action("LockUserPH", "ProvideHelp", new { transId = ts.Id })' class="doactive">Lock PH User</a>
                                                    }
                                                    else
                                                    {
                                                        <a href='@Url.Action("LockUserGH", "ProvideHelp", new { transId = item.Id })' class="doactive">Lock GH User</a>
                                                    }
                                                </td>
                                            </tr>
                                        }
                                    }
                                }

                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <!-- /.panel -->
        </div>
    </div>
    <div class="dataTables_paginate paging_full_numbers pull-riPHt" id="dyntable_paginate">
        @Html.PagedListPager((PagedList.IPagedList)Model, page => Url.Action("ListPH", new { page, bydate = ViewBag.ByDate, Fromdate = ViewBag.DateFrom, Todate = ViewBag.Todate }))
    </div>
    <script src="~/Scripts/fm.datetator-fo.jquery.js"></script>
    <link href="~/Scripts/fm.datetator.jquery.css" rel="stylesheet" />
    <script src="~/Scripts/fm.datetator.jquery.js"></script>
    <script type="text/javascript">
            $('.inputBox').datetator();
            $('.doactive').on('click', function () {
                return confirm('bạn có chắc chắn muốn kích hoạt ?');
            });
            $('.confirmation').on('click', function () {
                return confirm('bạn có chắc chắn muốn xóa?');
            });
    </script>
                                    }

